<settings>
  <localRepository>/repo</localRepository>

  <proxies>
{% if HTTP_PROXY %}
  {% set proxy = HTTP_PROXY %}
{% elif http_proxy %}
  {% set proxy = http_proxy %}
{% endif %}

{% if proxy %}
  {% set hostport = proxy.rpartition('//')[-1].partition('/')[0] %}
  {% if ':' in hostport %}
    {% set host, port = hostport.split(':', 1) %}
  {% else %}
    {% set host = hostport %}
    {% set port = '80' %}
  {% endif %}
    <proxy>
      <id>proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>{{ host }}</host>
      <port>{{ port }}</port>
    </proxy>
{% endif %}
  </proxies>
</settings>
